package com.user.dao;

import java.util.List;

import org.springframework.data.jpa.repository.JpaSpecificationExecutor;
import org.springframework.data.jpa.repository.Query;
import org.springframework.data.repository.PagingAndSortingRepository;
import org.springframework.stereotype.Repository;

import com.user.entity.Teacher;
@Repository
public interface TeacherRepository extends PagingAndSortingRepository<Teacher, Long>, JpaSpecificationExecutor<Teacher> {
	@Query(value="from Teacher t where t.num = ?1 and t.password = ?2")
	public Teacher findLogin(String num,String password);
	@Query(value="from Teacher t left join t.subjs s where s.id=?1")
	public List<Teacher> findBySubjectId(Long id);
	@Query(value="from Teacher t where t.department.id=?1")
	public List<Teacher> findByDeptId(Long id);
	@Query(value="from Teacher t where t.num=?1")
	public Teacher findByNum(String num);
	@Query(value="from Teacher t left join t.subjs s where s.id=?1 and t.revoked=false")
	public List<Teacher> findSelectingBySubj(Long id);
}
